package com.young.mybatis.v2.sqlnode;

import java.util.HashMap;
import java.util.Map;

/**
 * 描述:封装
 *
 * @author BluceYoung
 * @create 2020-07-04 9:32
 * B站：TeacherYoung凌风
 * www.teacheryoung.com
 */
public class DynamicContext {
    private StringBuffer sb = new StringBuffer();
    private Map<String,Object> bindings=new HashMap<String, Object>();

    public DynamicContext(Object params){
        bindings.put("_parameter",params);
    }

    public Map<String, Object> getBindings() {
        return bindings;
    }

    public void addBindings(String key,Object value) {
        this.bindings.put(key,value);
    }

    /**
     * 获取最终合并后的sql
     * @return
     */
    public String getSql(){
        return sb.toString();
    }

    public void appendSql(String sql){
        sb.append(sql);
        sb.append(" ");
    }
}
